<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GetYahoo
 *
 * @author mateusz.ledzewicz
 */
class GetMoney extends AbstractGet {
   
    const EUR = 'EUR';
    const USD = 'USD';
    const CHF = 'CHF';
    protected function init($dateFrom, $dateTo, $instrumentType, $isin) {
        $this->data = file_get_contents('http://www.bankier.pl/narzedzia/archiwum-kursow-walutowych/get_answer?op=4&cur_symbol='.$isin.'&start_dt='.$dateFrom.'&end_dt='.$dateTo.'&customs=0&table_name=0&fromDay=0&monthDay=1&avg=0&avg_type=1&idTable=gemiusHitSection16', false);    
        $this->createMapper();
    }
    
    public function getArray() {
        
      
       
        $array = parent::getArray();
        $array = array_slice($array, 3);
        $newArray = Array();
       
        foreach($array as $ar){  
            if(is_null($ar[self::$mapper[AbstractGet::date]]))
                break;
            $newArray[$ar[self::$mapper[AbstractGet::date]]] = $ar[self::$mapper[AbstractGet::closePrice]];
        }
        return $newArray;
        
    }

    protected function createMapper() {
        
        self::$mapper= array
        (
            'date'          => 0,
            'closePrice'    => 1,
            'volume'        => 2,
            
        );
        
    }
    

    
}

?>
